import 'package:flutter/material.dart';

class TabsComponents extends StatefulWidget {
  @override
  TabsComponentsState createState() => new TabsComponentsState();
}

class TabsComponentsState extends State<TabsComponents> {
  // 生成数据
  List<String> getDataList() {
    List<String> list = [];
    for (int i = 0; i < 20; i++) {
      list.add('推荐' + i.toString());
    }
    return list;
  }

  var height = 80.0;

  List<Widget> getWidgetList() {
    return getDataList().map((item) => getItemContainer(item)).toList();
  }

  Widget getItemContainer(String item) {
    return Container(
      margin: EdgeInsets.all(10), //容器外填充
      padding: EdgeInsets.all(10),
      constraints: BoxConstraints.tightFor(height: 16.0), //卡片大小
      decoration: BoxDecoration(
          //背景装饰
          gradient: RadialGradient(
              //背景径向渐变
              colors: [Colors.red, Colors.orange],
              center: Alignment.topLeft,
              radius: .98),
          boxShadow: [
            //卡片阴影
            BoxShadow(
                color: Colors.black54,
                offset: Offset(2.0, 2.0),
                blurRadius: 4.0)
          ]),
      alignment: Alignment.center, //卡片内文字居中
      child: Text(
        //卡片文字
        item, style: TextStyle(color: Colors.white, fontSize: 14.0),
      ),
    );
  }

  // @override
  // Widget build(BuildContext context) {
  //   return Container(
  //     height: height,
  //     child: ListView(
  //       scrollDirection: Axis.horizontal,
  //       children: [categoryTitle()],
  //     ),
  //   );
  // }
  @override
  Widget build(BuildContext context) {
    return Container(
        margin: const EdgeInsets.fromLTRB(10, 20, 10, 0),
        child: Text(
          "热门食谱",
          textAlign: TextAlign.left,
          style: TextStyle(fontSize: 30, fontWeight: FontWeight.bold),
        ));
  }
}
